package cc.demo02;

import java.lang.reflect.Method;

/**
 * @author ${崔灿}
 * @date 2022/10/27 09:53
 **/

public class Test01 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("cc.demo02.Cat");
        Method fun1 = aClass.getDeclaredMethod("fun1");
        System.out.println(fun1);

        Method fun2 = aClass.getDeclaredMethod("fun2",String.class,Integer.class);
        System.out.println(fun2);

        Method[] declaredMethods = aClass.getDeclaredMethods();
        for (Method methods : declaredMethods) {
            System.out.println(methods);
        }

        Method fun11 = aClass.getMethod("fun1");
        System.out.println(fun11);

        Method show = aClass.getMethod("show");
        System.out.println(show);

        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
    }
}
class Animal{
    public void show(){
        System.out.println("动物的show方法");
    }
    private void print(){
        System.out.println("动物的print方法");
    }
}
class Cat extends Animal{
    public void fun1(){
        System.out.println("Cat的fun1方法");
    }
    public void fun2(String name , Integer age){
        System.out.println("Cat 中fun2方法"+name);
    }
}